package com.ponhu.ea2.stockcenter.vo;

import com.ponhu.ea2.stockcenter.enums.ExchangeActionTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.ObjectUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Accessors(chain = true)
@ApiModel(value = "批次库存-数据传输模型 ")
public class StockBatchChangeVO implements Serializable {

    @ApiModelProperty(value = "货品编码")
    private String inventoryCode;

    @ApiModelProperty(value = "货品名称")
    private String inventoryName;

    @ApiModelProperty(value = "货品规格")
    private String unit;

    @ApiModelProperty(value = "批次编码")
    private String batchCode;

    @ApiModelProperty(value = "关联单据编号")
    private String directSn;

    @ApiModelProperty(value = "变动类型：true-入库，false-出库")
    private Boolean inOut;

    @ApiModelProperty(value = "关联单据类型", hidden = true)
    private Integer actionType;

    @ApiModelProperty(value = "关联单据类型")
    private String optRemark;

    @ApiModelProperty(value = "库存变动数量(区分正负数)")
    private Integer updatedNum;

    @ApiModelProperty(value = "操作前库存数")
    private Integer preStockNum;

    @ApiModelProperty(value = "操作后库存数")
    private Integer postStockNum;

    @ApiModelProperty(value = "操作时间")
    private LocalDateTime operatorTime;

    @ApiModelProperty(value = "操作人姓名")
    private String operatorName;

    public Boolean getInOut() {
        if (ObjectUtils.isEmpty(actionType)) return null;
        ExchangeActionTypeEnum actionEnum = ExchangeActionTypeEnum.getEnumByCode(actionType);
        if (ObjectUtils.isEmpty(actionEnum)) return null;
        return actionEnum.getInOut();
    }

}
